package com.anjubao.parking.municipal.parkinglot.controller;

import com.anjubao.parking.municipal.common.dto.ApiResult;
import com.anjubao.parking.municipal.parkinglot.dto.ParkingLotStatusDto;
import com.anjubao.parking.municipal.parkinglot.service.ParkingLotStatusService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 停车场状态基本api
 * @author anjubao.com
 *
 */


@RestController
@RequestMapping("/parking-lots-status")
@Api(value="ParkingLotStatus模块",tags = {"停车场状态接口"})
public class ParkingLotStatusController {

    private static final Logger logger = LoggerFactory.getLogger(ParkingLotStatusController.class);

    @Autowired
    private ParkingLotStatusService parkingLotStatusService;

    @GetMapping("")
    @ApiOperation(value = "最近100条停车场状态列表")
    @ApiResponses(value = {
            @ApiResponse(code = 5000,message = "操作失败")
    })
    @ApiImplicitParams({
            @ApiImplicitParam(name="cityId",value = "城市id",required = true,dataType = "int",paramType = "query")
    })
    /**
     * 查询
     *
     * @return
     */
    public ApiResult<List<ParkingLotStatusDto>> getStatusList(@RequestParam(name = "cityId") Integer cityId) {
        Page<ParkingLotStatusDto> page=new Page<>();
        page.setSize(100);
        page.setCurrent(1);
        IPage<ParkingLotStatusDto> resDtos=parkingLotStatusService.getStatusList(page,cityId);
        return ApiResult.success(resDtos.getRecords(), (int) resDtos.getTotal());
    }
}
